
<div class="card card-table mb-1">
	<div class="card-body page-body">
		<div class="row align-items-center oper-list">
			<div class="col-5"></div>
			<div class="col align-self-center text-end">
			#if(page.totalPage > 1)
				<div class="float-end">#@paginate(page.pageNumber, page.totalPage, "")</div>
			#end
			<div class="float-end me-3 mt-1">
					<input class="form-check-input" type="checkbox" name="hide_warn_flag" id="stockInfo_hide_warn_flag" #if(hideWarnFlag) checked #end onclick="stockInfo.list();"> 
					<label class="form-check-label me-3" for="stockInfo_hide_warn_flag"> 只显示预警商品</label>
					
					<input class="form-check-input" type="checkbox" name="hide_zero_flag" id="stockInfo_hide_zero_flag" #if(hideZeroFlag) checked #end onclick="stockInfo.list();"> 
					<label class="form-check-label me-3" for="stockInfo_hide_zero_flag"> 隐藏零库存商品</label>
					
					<input class="form-check-input" type="checkbox" name="hide_stop_flag" id="stockInfo_hide_stop_flag" #if(hideStopFlag) checked #end onclick="stockInfo.list();"> 
					<label class="form-check-label" for="stockInfo_hide_stop_flag"> 隐藏停用商品</label>
			</div>
			</div>
		</div>
	</div>
</div>

<table class="table table-hover table-bordered bg-white">
	<thead>
		<tr class="table-header">
			<th>图片</th>
			<th>商品名称</th>
			<th>商品条码</th>
			<th>单位</th>
			<th>总库存<span data-bs-toggle="tooltip" data-bs-placement="top" title="数字显示红色，表示库存预警"><i class="bi bi-question-circle"></i></span></th>
			<th>已订库存</th>
			<th>可用库存</th>
			<th>成本价<span data-bs-toggle="tooltip" data-bs-placement="top" title="根据每次进货加权平均计算"><i class="bi bi-question-circle"></i></span></th>
			<th>库存总金额<span data-bs-toggle="tooltip" data-bs-placement="top" title="库存总金额 = 库存数量 × 成本价"><i class="bi bi-question-circle"></i></span></th>
			<th style="width: 13%">操作</th>
		</tr>
	</thead>
	<tbody class="table-row" id="stockInfo-list">
		#for (x : page.getList())
		#set(goodsInfo = x.goodsInfo)
		<tr data-id="#(goodsInfo.id)" id="stockInfo-data-#(goodsInfo.id)" #if(goodsInfo.data_status == DataStatusEnum.disable.value) class="disable-order"  #end>
			
			<td>
			#set(mainThumb = goodsInfo.mainThumb)
			#if(mainThumb)
			   <img src="#(resourceUploadDomain)#(mainThumb.thumb)" layer-src="#(resourceUploadDomain)#(mainThumb.thumb)" alt="#(goodsInfo.name)" class="rounded" style="width:20px;">
			#else
			<i class="bi bi-image" style="color: #dedede;font-size:15px"></i>
			#end
			</td>
			<td><span class="fw-bold text-secondary">#(goodsInfo.name??)</span></td>
			<td>#(goodsInfo.bar_code??)</td>
			<td>#(goodsInfo.stockMainUnit.name??)</td>
			#if(x.isWarning())
			<td><span class="fw-bold text-danger">#number(x.sum_stock, "#.####")</span> </td>
			<td><span class="fw-bold text-danger">#number(x.sum_reserve_stock, "#.####")</span> </td>
			<td><span class="fw-bold text-danger">#number(x.sum_stock-x.sum_lock_stock, "#.####")</span> </td>
			#set(goodsPrice = x.goodsPriceByGoodsId)
			<td><span class="text-danger">￥#number(goodsPrice.sum_avg_cost_price??0/goodsPrice.counts??1, "#.##")</span></td>
			<td><span class="text-danger">￥#number((goodsPrice.sum_avg_cost_price??0/goodsPrice.counts??1)*x.sum_stock??0, "#.##") </span> </td>
			
			#else
			<td><span class="fw-bold text-success">#number(x.sum_stock, "#.####")</span> </td>
			<td><span class="fw-bold text-success">#number(x.sum_reserve_stock, "#.####")</span> </td>
			<td><span class="fw-bold text-success">#number(x.sum_stock-x.sum_lock_stock, "#.####")</span> </td>
			#set(goodsPrice = x.goodsPriceByGoodsId)
			<td><span class="text-success">￥#number(goodsPrice.sum_avg_cost_price??0/goodsPrice.counts??1, "#.##")</span></td>
			<td><span class="text-success">￥#number((goodsPrice.sum_avg_cost_price??0/goodsPrice.counts??1)*x.sum_stock??0, "#.##") </span></td>
			
			#end
			
			<td>
				<button type="button" class="btn btn-sm sm-more  #if(x.isWarning()) btn-outline-danger #else btn-outline-primary  #end" onclick="stockInfo.show(#(goodsInfo.id));">库存分布</button> 
				<button type="button" class="ms-1 btn btn-sm sm-more  #if(x.isWarning()) btn-outline-danger #else btn-outline-primary  #end" onclick="stockInfo.showLog(#(goodsInfo.id));">流水</button> 
			</td>
		</tr>
		#end

	</tbody>
</table>

<script type="application/javascript">
	
$(function() {
	// 初始化bootstrap相关组件
	common.initBootstrap();
	
	beekit.photos("#stockInfo-list");
	
	// 滚动表头处理
	common.tableFixedWidth();
	common.tableFixed();
	$(".main").scroll(function() {
		common.tableFixed();
	});
	$("#stockInfo_pageNumber").val(#(page.pageNumber));
	
	$("#stockInfo-list tr").on("dblclick", function() {
		stockInfo.show($(this).attr("data-id"));
	});
	
});

stockInfo.show = function(id) {
	beekit.offcanvas("/inventory/stock/info/show?id="+id);
};

stockInfo.showLog = function(id) {
	beekit.offcanvas("/inventory/stock/info/showLog?id="+id);
};




</script>
